<template>
  <div id="app">
    <h2>学生姓名:{{name}}</h2>
    <h2>学生年龄:{{age}}</h2>
    <button @click="sendStudentName">点我将名字给School</button>
  </div>
</template>

<script>
import pubsub from 'pubsub-js'
export default {
  name: "Student",
  data(){
    return{
      name:'xccit',
      age:21
    }
  },
  methods:{
    sendStudentName(){
      // this.$bus.$emit('hello',this.name)
      //消息发布
      pubsub.publish('hello',this.name)
    }
  }
}
</script>

<style scoped>
  #app{
    background-color: #eee;
  }
</style>